import 'package:flutter/material.dart';
/// 底层通过[Transform]实现，且这里的变化只是图像的变化，控件本身大小是不变的
class ScaleView extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _ScaleState();
  }
}

class _ScaleState extends State<ScaleView> {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        GestureDetector(
            onTap: () {
              print("click area");
            },
            child: Container(color: Colors.green, child: _generateChild())),
        GestureDetector(
            onTap: () {
              print("click area");
            },
            child: Container(color: Colors.blue, child: _generateChild2()))
      ],
    );
  }

  Widget _generateChild2() {
    return ClipRect(
        child: Align(
          alignment: Alignment.bottomCenter,
          widthFactor: 0.5,
          heightFactor: 0.5,
          child: Image.asset("images/birds_by_pond.jpg"),
        ));
  }

  Widget _generateChild() {
    return Transform(
      transform: Matrix4.identity()..scale(0.5, 0.5),
      child: Image.asset("images/birds_by_pond.jpg"),
    );
  }
}
